package com.huizu.project.apiController;

import com.huizu.common.annotation.Anonymous;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.core.page.TableDataInfo;
import com.huizu.common.enums.BusinessType;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.project.domain.ProNotice;
import com.huizu.project.service.IProNoticeService;
import com.huizu.project.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 公告管理Controller
 * 
 * @author zhangmx
 * @date 2024-05-25
 */
@Anonymous
@RestController
@RequestMapping("/api/pronotice")
public class ApiProNoticeController extends BaseController
{
    @Autowired
    private IProNoticeService proNoticeService;

    /**
     * 查询公告管理列表
     */
    @PostMapping("/list")
    public TableDataInfo list(ProNotice proNotice, HttpServletRequest request)
    {
        String token = request.getHeader(TokenUtils.getAppTokenHeader());
        String userId = TokenUtils.parseToken(token);//获取用户id
        proNotice.setBeUserId(userId);
        startPage();
        List<ProNotice> list = proNoticeService.selectProNoticeListApi(proNotice);
        return getDataTable(list);
    }




    /**
     * 获取公告管理详细信息
     */
    @PostMapping(value = "/getById")
    public AjaxResult getInfo(@RequestBody ProNotice proNotice)
    {
        String id = proNotice.getId();
        return success(proNoticeService.selectProNoticeById(id));
    }

}
